/**
 * 项目名：admin
 * 包名：com.xuebang.admin.mapper
 * 文件名：SlideMapper.java
 * 版本信息：@version 1.0
 * 日期：2014-2-17-下午3:51:13
 */
package com.xuebang.admin.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

import com.xuebang.admin.entity.Links;

/**
 * 项目名称：admin
 * 类名称：SlideMapper
 * 类描述：
 * 创建人：xuyang
 * 创建时间：2014-2-17 下午3:51:13
 * 修改人：xuyang
 * 修改时间：2014-2-17 下午3:51:13
 * 修改备注：
 * @version 
 */
public interface LinkMapper extends BaseMapper<Links> {
	
	/**
	 * 通过id查找
	 */
	@Select("select * from links where id=#{intLink}")
	public Links loadLink(Integer intLink);

	/**
	 * 展示幻灯片
	 */
	@Select("select * from links where type=1 order by sort desc,posttime desc,id desc")
	public List<Links> showSlides();
	/**
	 * 查询幻灯片
	 */
	public List<Links> findLinks(@Param("strLinkIDs")String[] strLinkIDs);
	
	/**
	 * 展示公告
	 */
	@Select("select * from links where type=2 order by sort desc,posttime desc,id desc")
	public List<Links> showAds();
	
	/**
	 * 增加
	 */
	@Insert("insert into links(id,type,pic,theme,url,sort,posttime,iftop,cid,reserved) " +
			"values(#{id},#{type},#{pic},#{theme},#{url},#{sort},#{posttime},#{iftop},#{cid},#{reserved})")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", before = false, resultType = Integer.class)
	public void addLinks(Links link);
	
	/**
	 * 更新
	 */
	@Update("update links set type=#{type},pic=#{pic},theme=#{theme},url=#{url},sort=#{sort}," +
			"posttime=#{posttime},iftop=#{iftop},cid=#{cid},reserved=#{reserved} where id=#{id}")
	public void updateLinks(Links link);
	
	/**
	 * 删除
	 */
	public void deleteLinks(@Param("strLinkIDs")String[] strLinkIDs);
	
	/**
	 * 获得某种类型的数目
	 */
	@Select("select count(id) from links where type=#{type}")
	public Integer getLinksNum(Integer type);
}
